<template>
  <div id="papertaskdetail" v-loading="loading">
  <v-table :pageSize="pageSize"
           :page="page"
           :tableConfig="tableConfig"
           :tableData="tableData"
           :total="total"
           :checked="false"
           @findData="getTableData"
           @getTableData="getTableData"
           @searhData="setSearhData"
           @selectData="setSelectData"
           @upData="getTableData"
           @setdialog="setdialog"
           ref="table"></v-table>
  </div>
</template>

<script>
import table from 'commons/Table'
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "Table",
  mixins: [baseMixin],
  props: {
    data: {
      type: Object
    }
  },
  data () {
    return {
      tableConfig: [
        {
          label: this.$t('out.taskgroup'),
          prop: "rtxtaskgrp",
          input: "input",
        },
        {
          label: this.$t('out.wavekey'),
          prop: "wavekey",
          input: "input",
        },
        {
          label: this.$t('security.userName'),
          prop: "userkey",
          input: "input",
        },
        {
          label: this.$t('out.starttime'),
          prop: "starttime",
          input: "date",
        },
        {
          label: this.$t('out.endtime'),
          prop: "endtime",
          input: "date",
        },
        {
          label: this.$t('common.status'),
          prop: "status",
          input: "select",
          options: this.getOptions("codelkup/TMSTATUS")
        },
        {
          label: this.$t('in.priority'),
          prop: "priority",
          input: "select",
          options: this.getOptions("codelkup/PRIORITY")
        },
        {
          label: this.$t('config.sku'),
          prop: "sku",
          input: "input",
        },
        {
          label: this.$t('config.shipper'),
          prop: "storerkey",
          input: "input",
        },
        {
          label: this.$t('outbound.fromloc'),
          prop: "fromloc",
          input: "input",
        },
        {
          label: this.$t('config.toLoc'),
          prop: "toloc",
          input: "input",
        },
        {
          label: this.$t('config.num'),
          prop: "qty",
          input: "input",
        },
      ],
      tableData: [],
      pageSize: 10,
      page: 1,
      total: 10,
      searhData: {}
    }
  },
  methods: {
    //获取table数据
    async getTableData (page, data) {
      data.tasktype = "PAPK"
      try {
        this.loading = true;
        let res = await this.$api.post(`/queryTaskdetailList/${page}`, data);
        
          this.tableData = res.page.list;
          this.pageSize = res.page.pageSize;
          this.page = res.page.curpage;
          this.total = res.page.total;
        
      } catch (e) {
        this.$message.error(e);
      } finally {
        this.loading = false;
      }
    },
    //搜索值
    setSearhData (data, up) {
      if (!up) {
        this.searhData = data;
      } else {
        this.searhData = data;
        this.getTableData(1, this.searhData);
      }
    },
    //选中的数据
    setSelectData (data) {
      this.$parent.setSelectData(data)
    },
    setdialog(data) {
      this.$store.commit("setRouteData", data);
      this.$router.push({name: 'papertaskdetailDeawer'});
    },
  },
  mounted () {
    // this.getTableData(1, {})
    this.$store.commit("setSkip", {});
    this.$store.commit("setNewFlag", false);
    this.$store.commit("setRouteData", {});
  },
  components: {
    'v-table': table
  }
}
</script>

<style scoped>
#papertaskdetail {
  width: 100%;
  height: 30%;
  padding-top: 6px;
}
</style>
